//
//  XMFilterViewController.m
//  XMFilterView
//
//  Created by mac on 2019/11/25.
//  Copyright © 2019 aishangliguo. All rights reserved.
//

#import "XMFilterViewController.h"

@interface XMFilterViewController () <UIGestureRecognizerDelegate>

@end

@implementation XMFilterViewController

- (instancetype)init {
    if (self = [super init]) {
        UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dissMissPopViewController:)];
        tapGestureRecognizer.delegate = self;
        [self.view addGestureRecognizer:tapGestureRecognizer];
    }
    return self;
}

- (void)dissMissPopViewController:(UIGestureRecognizer *)recognizer {
    if (self.delegate && [self.delegate respondsToSelector:@selector(viewDidMissViewController:)]) {
        [self.delegate viewDidMissViewController:self];
    }
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    if ([touch.view isDescendantOfView:self.filterView]) {
        return NO;
    }
    return YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self.view addSubview:self.filterView];
    [UIView animateWithDuration:.5 animations:^{
        self.filterView.frame = CGRectMake(44, 0, self.view.bounds.size.width - 44, self.view.bounds.size.height);
            self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.75f];
    } completion:^(BOOL finished) {
        
    }];
    
    self.filterView.dataSource = @[@{
                                       @"title":@"品牌",
                                       @"name":@[@{
                                                     @"content":@"瞄可",
                                       },@{
                                                     @"content":@"博多客",
                                       },@{
                                                     @"content":@"储山",
                                       },@{
                                                     @"content":@"国祥",
                                       },@{
                                                     @"content":@"街坊",
                                       },@{
                                                     @"content":@"零时",
                                       },@{
                                                     @"content":@"描述",
                                       },]
    },
    @{
                                       @"title":@"地址",
                                       @"name":@[@{
                                                 @"content":@"东莞",
                                       },@{
                                                 @"content":@"深圳",
                                       },@{
                                                 @"content":@"佛山",
                                       },@{
                                                 @"content":@"广州",
                                       },@{
                                                 @"content":@"北京",
                                       },@{
                                                 @"content":@"上海",
                                       }]
    }];
    
    
    
}

- (XMFilterView *)filterView {
    if (!_filterView) {
        _filterView = [[XMFilterView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width, 0, self.view.bounds.size.width - 44, self.view.bounds.size.height)];
    }
    return _filterView;
}

@end
